package com.flyemu.share.entity;

import com.flyemu.share.enums.Priority;
import com.flyemu.share.enums.TodoState;
import com.flyemu.share.enums.TodoType;
import jakarta.persistence.*;
import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.Setter;
import org.hibernate.annotations.Comment;
import org.hibernate.annotations.CreationTimestamp;

import java.io.Serializable;
import java.time.LocalDate;
import java.time.LocalDateTime;
import java.util.Date;
import java.util.Objects;

/**
 * @功能描述: 代办清单
 * @创建时间: 2023年08月08日
 * @公司官网: www.fenxi365.com
 * @公司信息: 纷析云（杭州）科技有限公司
 * @公司介绍: 专注于财务相关软件开发, 企业会计自动化解决方案
 */
@Getter
@Setter
@Entity
@NoArgsConstructor
@Table(uniqueConstraints = {@UniqueConstraint(columnNames = {"name", "merchantId"})})
public class TodoList implements Serializable {

    private static final long serialVersionUID = -30398395829850927L;

    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    private Integer id;
    @Comment("用户ID")
    private Integer adminId;

    @Comment("项目ID")
    private Integer projectId;

    @Comment("标题")
    private String name;

    @Comment("状态")
    @Enumerated
    private TodoState todoState;

    @Comment("优先级")
    @Enumerated
    private Priority priority;

    @Comment("代办类型")
    @Enumerated
    private TodoType todoType;

    @Comment("创建时间")
    @CreationTimestamp
    @Column(updatable = false)
    private LocalDateTime createDate;

    @Comment("开始时间")
    @Column(updatable = false)
    private LocalDate startDate;

    @Comment("结束时间")
    @Column(updatable = false)
    private LocalDate endDate;

    private Integer merchantId;

    @Override
    public boolean equals(Object o) {
        if (this == o) return true;
        if (o == null || getClass() != o.getClass()) return false;
        TodoList todoList = (TodoList) o;
        return id.equals(todoList.id);
    }

    @Override
    public int hashCode() {
        return Objects.hash(id);
    }
}

